Len and Length (str) are equivalent functions. However, Len is preferred in Basic syntax whereas Length is preferred in Crystal syntax.
Len returns a Number indicating the length of the given string.
Note: Text strings must be enclosed in quotation marks. Any blank spaces are included as part of the character count.
Use this function any time you have a manipulation, comparison, or calculation that is dependent on the length of a text string.
The following examples are applicable to both Basic and Crystal syntax:
Returns 11. The blank space between "Text" and "String" is counted as a character.
Returns 10. There are 2 spaces on either side of the word "Center".
Len(ToText({orders.ORDER AMOUNT}))
Returns 9, where {orders.ORDER AMOUNT} is 14233.08, and ToText ({orders.ORDER AMOUNT}) returns the String "14,233.08". Here, the comma and period have been specified in the Number format for the formula field as the thousands and decimal separators respectively.
Len(ToText({orders.ORDER AMOUNT}, 2, "", "."))
Returns 8 where {orders.ORDER AMOUNT} = 14233.08, and ToText ({orders.ORDER AMOUNT}, 2, "", ".") returns the String "14233.08". Here, the null character and period have been specified in the Number format for the formula field as the thousands and decimal separators respectively.
The length of the text string stored as a value in {customer.CUSTOMER NAME}.
The following examples are applicable to Basic syntax:
{customer.CUSTOMER NAME} (Len({customer.CUSTOMER NAME})
Returns the third character from the right in the Customer Name. This can also be used to extract a substring from a String that always starts at a fixed position from the end of the String.
In the following example, an address line contains the province name and postal code. Full province names are of different lengths; however, a postal code has a fixed number of characters: the first character of the postal code is always the seventh from the last character in the String. The formula determines the length of the address line, subtracts 7 from it, and uses the result to identify the first character of the postal code in the address line.
addressLine = "British Columbia V6X 3W2"
addressLen = Len (addressLine)
formula = addressLine (addressLen
This function is designed to work like the Visual Basic function of the same name.
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |